<?php 
//End//Lay danh sach cac the XML va gia tri tuong ung voi tung the do
$v_username = "";
if(isset($_REQUEST['txt_username'])){
	$v_username = _replace_bad_char($_REQUEST['txt_username']);
}
$v_old_password = "";
if(isset($_REQUEST['txt_old_password'])){
	$v_old_password = _replace_bad_char($_REQUEST['txt_old_password']);
}
$v_new_password = "";
if(isset($_REQUEST['txt_new_password'])){
	$v_new_password = _replace_bad_char($_REQUEST['txt_new_password']);
}
//Ma hoa mat khau
$v_old_password = md5($v_old_password);
$v_new_password = md5($v_new_password);
$v_goto_url = "index.php?modal_dialog_mode=1&fuseaction=DISPLAY_CHANGE_PASSWORD";

if(_is_sqlserver()){
	//Cap nhat noi dung cau hoi
	$sql = "Exec Onegate_ChangePassword " ;
	$sql = $sql . "'" . $v_username . "'"  ;
	$sql = $sql . ",'" . $v_old_password ."'";
	$sql = $sql . ",'" . $v_new_password . "'" ;
	//echo $sql; exit;
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$rs = $ado_conn->GetRow($sql); 
	$v_error = _replace_bad_char(trim($rs['RET_ERROR']));
}
sleep(0);
if (!is_null($v_error) && $v_error<>""){?>
	<script>
		alert("<?php echo $v_error; ?>");
		if (_MODAL_DIALOG_MODE==1){
			window.location = "<?php echo $v_goto_url; ?>";
		}else{
			window.history.back();
		}	
	</script><?php
	exit;
}
?>
<form action="index.php" method="post" name="f_back">
	<input type="hidden" name="fuseaction" value="DISPLAY_SINGLE_CITIZEN">
</form>
<Script language="javascript">
	alert("Bạn đã đổi mật khẩu thành công.");
	window.close();
</Script>